package com.yf.zzmusic.utils;

import com.aliyun.oss.common.auth.CredentialsProviderFactory;
import com.aliyun.oss.common.auth.EnvironmentVariableCredentialsProvider;
import com.aliyuncs.exceptions.ClientException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 时间：2024年2月26日 09点49分
 * 阿里云oss访问凭证，这里我们暂时写死
 * 这里我们用JavaBean的方式抛出
 * 注意，只有get方法，没有set方法
 *
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Slf4j
public class AliyunOssUtils{
  // 从环境变量中获取RAM用户的访问密钥(AccessKey ID和AccessKey Secret)
  private final String accessKeyId = "LTAI5tBXeSiSXnEh9ZiEmMky";
  private final String accessKeySecret = "sqVrrzZhr9Rg3CRf5fzfhq3OhvY1Rf";
  private final String bucketName="bucket-yufei";
  private final String endpoint = "oss-cn-beijing.aliyuncs.com";
  // 从环境变量中获取访问凭证。运行本代码示例之前，请确保已设置环境变量OSS_ACCESS_KEY_ID和OSS_ACCESS_KEY_SECRET。
  private EnvironmentVariableCredentialsProvider credentialsProvider;

  {
    try {
      credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
    } catch (ClientException e) {
      throw new RuntimeException(e);
    }
  }

  public String getAccessKeyId() {
    return accessKeyId;
  }

  public String getAccessKeySecret() {
    return accessKeySecret;
  }

  public String getBucketName() {
    return bucketName;
  }

  public String getEndpoint() {
    return endpoint;
  }
  public EnvironmentVariableCredentialsProvider getCredentialsProvider() {
    return credentialsProvider;
  }
}
